
package com.yimixian.app.common;

import com.yimixian.app.R;

import android.view.LayoutInflater;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

public abstract class YmxTitleBarActivity extends YmxActivity {

    public FrameLayout mAllContentFrame;
    public FrameLayout mContentFrame;
    public FrameLayout mTopBar;
    private TextView mTitleText;
    public  ImageView backButton;
    public  ImageView closeButton;
    public  FrameLayout mTop;
    @Override
    public void setContentView(int layoutResID) {
        super.setContentView(R.layout.ymx_title_bar_activity);
        getWindow().getDecorView().setBackgroundColor(
            getResources().getColor(R.color.app_background_grey));
        backButton = (ImageView) findViewById(R.id.title_bar_activity_back_button);
        closeButton = (ImageView) findViewById(R.id.title_bar_activity_close);
        mTitleText = (TextView) findViewById(R.id.title_bar_activity_title_text);
        mTopBar = (FrameLayout) findViewById(R.id.fl_top);
        mContentFrame = (FrameLayout) findViewById(R.id.title_bar_activity_content_frame);
        mAllContentFrame = (FrameLayout) findViewById(R.id.all_content_frame);
        mTop = (FrameLayout) findViewById(R.id.fl_top_bar);

        LayoutInflater.from(this).inflate(layoutResID, mContentFrame);
        mTitleText.setText(getTitleBarText());
        backButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
        closeButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
    }

    protected abstract String getTitleBarText();

    protected void refreshTitleText() {
        mTitleText.setText(getTitleBarText());
    }
    public void hideTopBar(){
        mTop.setVisibility(View.GONE);
    }
    public void showCloseButton(){
        closeButton.setVisibility(View.VISIBLE);
    }
}
